if (window.addEventListener) window.addEventListener('load', loadExtras, false); 
else if (window.attachEvent) window.attachEvent('onload', loadExtras);
function loadExtras() {
   var topScroller=document.getElementById('top-scroller');
   var imgScroller=document.getElementById('base-points');
   var lastUpdated=document.getElementById('last-updated');
   var copyrightText=document.getElementById('copyright');
   var contactData=document.getElementById('contact');
   if(topScroller!=null) loadTopScroller();
   if(imgScroller!=null) loadImgScroller();
   if(lastUpdated!=null) lastUpdated.getElementsByTagName("strong")[0].innerHTML=getthedate();
   if(copyrightText!=null) loadCountryFlags();
   if(contactData!=null) loadContactData();
}

function goForm(ft) {
      if(window.autocloseForm!=null) clearInterval(autocloseForm);
      if (ft!='close') {
            var topmatchwfdiv = document.getElementById('topmatch-webform-screen');
            if(topmatchwfdiv) { 
                  try {
                        document.body.removeChild(topmatchwfdiv);
                  } catch(err){
                        topmatchwfdiv.removeNode(true); 
                  }
            }
            var topmatchwfdiv = document.createElement('div');
            topmatchwfdiv.setAttribute('id', 'topmatch-webform-screen');
            document.body.appendChild(topmatchwfdiv);
            document.getElementById('topmatch-webform-screen').innerHTML='<div id="topmatch-webform-content"></div><a href="javascript:goForm(\'close\');" id="close-topmatch-form-screen" title="Close This Screen">close [x]</a>'; 
            document.getElementById('topmatch-webform-content').innerHTML = "<div id=\"loading\"><img src=\"[img]/loading-24.gif\"/> Loading Data . . .</div>";
            var script = document.createElement("script");
            script.type = "text/javascript";
            script.src = "[incl]/[webform].js";
            var css = document.createElement("link");
            css.href = "[incl]/[webform].css";
            css.type="text/css";
            css.rel="stylesheet"; 
            if (script.readyState){  //IE
                  script.onreadystatechange = function(){
                        if (script.readyState == "loaded" || script.readyState == "complete"){
                              script.onreadystatechange = null;
                              LoadWebForm(ft);
                        }
                  };
            } else {  //Others
                  script.onload = function(){
                        LoadWebForm(ft);
                  };
            }
            document.getElementsByTagName("head")[0].appendChild(css);
            document.getElementsByTagName("head")[0].appendChild(script);
      } else {
            var topmatchwfdiv = document.getElementById('topmatch-webform-screen');
            try {
                  document.body.removeChild(topmatchwfdiv);
            } catch(err){
                  topmatchwfdiv.removeNode(true); 
            }
      }
}

function goVideo(cliprefno) {
      if (cliprefno!='close') {
            var topmatchwfdiv = document.getElementById('topmatch-webform-screen');
            if(topmatchwfdiv) { 
                  try {
                        document.body.removeChild(topmatchwfdiv);
                  } catch(err){
                        topmatchwfdiv.removeNode(true); 
                  }
            }
            var vpdiv = document.createElement('div');
            vpdiv.setAttribute('id', 'video-player-screen');
            document.getElementById('content').appendChild(vpdiv);
            document.getElementById('video-player-screen').innerHTML='<div id="video-player"></div><a href="javascript:goVideo(\'close\');" id="close-player" title="Close Video">close</a>'; 
            document.getElementById('video-player-screen').style.display = 'block';
            document.getElementById('video-player-screen').style.zIndex = '100';
            var script = document.createElement("script");
            script.type = "text/javascript";
            script.src = "[incl]/[video].js";
            var css = document.createElement("link");
            css.href = "[incl]/[video].css";
            css.type="text/css";
            css.rel="stylesheet"; 
            if (script.readyState){  //IE
                  script.onreadystatechange = function(){
                        if (script.readyState == "loaded" || script.readyState == "complete"){
                              script.onreadystatechange = null;
                              PlayVideo(cliprefno);
                        }
                  };
            } else {  //Others
                  script.onload = function(){
                        PlayVideo(cliprefno);
                  };
            }
            document.getElementsByTagName("head")[0].appendChild(css);
            document.getElementsByTagName("head")[0].appendChild(script);
      } else {
            var videodiv=document.getElementById('video-player-screen');
            try {
                  document.body.removeChild(videodiv);
            } catch(err){
                  videodiv.removeNode(true); 
            }
      }
} 

var xmlDirectorDoc=null;
function goDirector(request) {
      if (request!='close') {
            var topmatchDdiv = document.createElement('div');
            topmatchDdiv.setAttribute('id', 'topmatch-director-panel');
            document.getElementById('base').appendChild(topmatchDdiv);
            if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest(); } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP"); } // Internet Explorer 5/6
            var url="./[incl]/topmatch-panels-generator.xml";
            url=url+"?director=request&sid="+Math.random();
            xhttp.open("GET",url,false);
            xhttp.send("");
            xmlDirectorDoc=xhttp.responseXML;
            if (xmlDirectorDoc!=null) {
                  var x=xmlDirectorDoc.getElementsByTagName("director");
                  if (x.length>0) {
                        var content="";
                        if(request!='expert-page') {
                              content+="<span class=\"click-for-details\">Click for details . . .</span>";
                        }
                        content+="<img src=\"[img]/director.png\" alt=\""+x[0].getElementsByTagName("director_name")[0].childNodes[0].nodeValue+" - Director Page1 Google Expert "+x[0].getElementsByTagName("area_name")[0].childNodes[0].nodeValue+"\">";
                        content+="<p>"+x[0].getElementsByTagName("director_name")[0].childNodes[0].nodeValue+" - Director<br />Page1 Google Expert "+x[0].getElementsByTagName("area_name")[0].childNodes[0].nodeValue+"<\p>";
                        document.getElementById('topmatch-director-panel').innerHTML = content;
                  }
            } else { document.write("Error loading Form Data(xml-pannels-file)"); }
      } else {
            var topmatchDdiv = document.getElementById('topmatch-director-panel');
            if(topmatchDdiv!=null) {
                  try {
                        document.getElementById('base').removeChild(topmatchDdiv);
                  } catch(err){
                        topmatchDdiv.removeNode(true); 
                  }
            }
      }
}

function loadTopScroller() {
      var script = document.createElement("script");
      script.type = "text/javascript";
      script.src = "[incl]/[top-scroll].js";
      if (script.readyState){  //IE
            script.onreadystatechange = function(){
                  if (script.readyState == "loaded" || script.readyState == "complete"){
                        script.onreadystatechange = null;
                        fadeUpTitle();
                  }
            };
      } else {  //Others
            script.onload = function(){
                  fadeUpTitle();
            };
      }
      document.getElementsByTagName("head")[0].appendChild(script);
}

function loadImgScroller() {
      var script = document.createElement("script");
      script.type = "text/javascript";
      script.src = "[incl]/[img-scroll].js";
      if (script.readyState){  //IE
            script.onreadystatechange = function(){
                  if (script.readyState == "loaded" || script.readyState == "complete"){
                        script.onreadystatechange = null;
                        loadJQuery();
                  }
            };
      } else {  //Others
            script.onload = function(){
                  loadJQuery();
            };
      }
      document.getElementsByTagName("head")[0].appendChild(script);
}

var xmlContactDataDoc=null;
function loadContactData() {
            if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest(); } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP"); } // Internet Explorer 5/6
            var url="./[incl]/topmatch-panels-generator.xml";
            url=url+"?contact-panel-data=request&sid="+Math.random();
            xhttp.open("GET",url,false);
            xhttp.send("");
            xmlContactDataDoc=xhttp.responseXML;
            if (xmlContactDataDoc!=null) {
                  var x=xmlContactDataDoc.getElementsByTagName("contact_data");
                  if (x.length>0) {
                        document.getElementById("phone").innerHTML=x[0].getElementsByTagName("area_phone")[0].childNodes[0].nodeValue;
                        var phonesQ=document.getElementsByTagName("q");
                        if(phonesQ.length>0) {
                              for(var i=0;i<phonesQ.length;++i){
                                    if(phonesQ[i].title=="phone") phonesQ[i].innerHTML=x[0].getElementsByTagName("area_phone")[0].childNodes[0].nodeValue;
                              }
                        }
                        var emailSpace=document.getElementById('contact').getElementsByTagName("a")[2];
                        emailSpace.innerHTML=x[0].getElementsByTagName("area_mail")[0].childNodes[0].nodeValue;
                        if(x[0].getElementsByTagName("area_mobile").length>0) {
                              var mobileSpace=document.getElementById('contact').getElementsByTagName("span")[1];
                              mobileSpace.innerHTML="Mobile: <strong>"+x[0].getElementsByTagName("area_mobile")[0].childNodes[0].nodeValue+"</strong><br />"+mobileSpace.innerHTML;
                        }
                  }
            } else { alert("Error loading Contact Data(xml-pannels-file)"); }
}

function contactOptions() {
      var divel=document.getElementById('contact');
      var ael=document.getElementById('contact-options');
      if (divel.style.height!='auto') {
            divel.style.height="auto";
            ael.style.backgroundImage="url([img]/hidden-content-hide-link.png)";
            ael.innerHTML="Hide contact options";
            ael.title="Hide contact options"
      } else {
            divel.style.height="50px";
            ael.style.backgroundImage="url([img]/hidden-content-link.png)";
            ael.innerHTML="More contact options";
            ael.title="Show all contact options"
      }
}

function MtL(a) { // MailToLink
      var link=a.innerHTML
      location.assign("mailto:"+link);
}

function getthedate() {
      var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
      var today=new Date();
      today.setDate(today.getDate()-3);
      date=today.getDate();
      month=today.getMonth();
      year=today.getYear();
      if (year<1900) {year=year+1900}
      return(date+' '+montharray[month]+' '+year+'.');
}

function loadCountryFlags() {
   var copyrightText=document.getElementById('copyright');
   copyrightText.innerHTML+=  " <a href=\"http://www.topmatch-uk.com\" title=\"TopMatch UK\"><img src=\"http://www.topmatch-uk.com/[img]/flags/flag_uk.gif\" alt=\"UK\"/></a>"+
                              " <a href=\"http://www.topmatch.ie\" title=\"TopMatch Ireland\"><img src=\"http://www.topmatch-uk.com/[img]/flags/flag_ie.gif\" alt=\"Ireland\"/></a>"+
                              " <a href=\"http://www.topmatch-canada.com\" title=\"TopMatch Canada\"><img src=\"http://www.topmatch-uk.com/[img]/flags/flag_ca.gif\" alt=\"Canada\"/></a>"+
                              " <a href=\"http://www.topmatch-usa.com\" title=\"TopMatch USA\"><img src=\"http://www.topmatch-uk.com/[img]/flags/flag_us.gif\" alt=\"USA\"/></a>";
}

function hiddenContent(go) {
      var divel=document.getElementById('hidden-content');
      var ael=document.getElementById('hidden-content-link');
      if (ael.innerHTML!='...') {
            divel.style.display="block";
            ael.innerHTML="...";
            ael.style.backgroundImage="url([img]/hidden-content-hide-link.png)";
            if(go.length>0) {
                  window.location.assign("#"+go);
                  colorFade(document.getElementById(go),'color','ff9900','000000','100','50');
            }
      } else {
            if(!go) {
                  divel.style.display="none";
                  ael.style.backgroundImage="url([img]/hidden-content-link.png)";
                  if(!document.URL.match("your-questions-answered.html")) {
                        ael.innerHTML="Click to read more . . .";
                  } else {
                        ael.innerHTML=" Click for all answers . . .";
                  }
            } else {
                  window.location.assign("#"+go);
                  colorFade(document.getElementById(go),'color','000000','ff9900','100','50');
            }
      }
}